package com.cn.qtms.util;

import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

/**
 * @Name:HttpUtil
 * @Description:
 * @Author: Neil
 * @Date: 2019-10-29 16:44
 **/
@Service
public class HttpUtil {


    public  String client(String url,HttpMethod method, MultiValueMap<String,Object> params){
        RestTemplate template = new RestTemplate();
        String  result = null;
        if(method.equals(HttpMethod.GET)){
            result = template.getForEntity(url,String .class).getBody();
        }else if(method.equals(HttpMethod.POST)){
            result = template.postForEntity(url,params, String .class).getBody();
        }
        return result;
    }

}
